# encoding=utf-8
# author:梁子龙
from db.dao import BaseDAO
from api.user_mgt.user_schemas import CreateUserSchema
from db.user.user_models import UserModel
from sqlalchemy import select


class UserDao(BaseDAO[UserModel, CreateUserSchema]):
    model = UserModel

    def get_user_by_username(self, session, username):
        """

        :param session:
        :param username:
        :return:
        """
        stmt = select(self.model).where(self.model.username == username)
        return session.execute(stmt).scalars().first()
